<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="__STATIC__/js/jquery.js"></script>
    <script src="__STATIC__/layui/layui.js"></script>
    <script src="__STATIC__/bootstrap-table/js/bootstrap-table.js"></script>
    <script src="__STATIC__/bootstrap-table/js/bootstrap-table-zh-CN.min.js"></script>
    <script src="__STATIC__/bootstrap-table/js/dropdown.js"></script>
    <link rel="stylesheet" href="__STATIC__/bootstrap-table/css/bootstrap-table.min.css">
    <link rel="stylesheet" href="__STATIC__/bootstrap-table/css/bootstrap.css">
    <script type="text/javascript" src="__STATIC__/x-admin/js/xadmin.js"></script>
    <link rel="stylesheet" href="__STATIC__/x-admin/css/font.css">
    <link rel="stylesheet" href="__STATIC__/x-admin/css/xadmin.css">
</head>
<body>
<form class="layui-form" action="" style="width: 30%;" onsubmit="return false">
    <br>
    <input type="text" id="id" hidden value="{$data.id}">
    <div class="layui-form-item">
        <label class="layui-form-label">标题</label>
        <div class="layui-input-block">
            <input type="text" id="title" name="title" value="{$data.title}" required  lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">内容</label>
        <div class="layui-input-block">
            <textarea id="demo" style="display: none;">{$data.contents}</textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="formDemo" id="add">立即提交</button>
            <button id="back" class="layui-btn layui-btn-primary">返回</button>
        </div>
    </div>
</form>
</body>
</html>
<script>
    layui.use('layedit', function(){
        layedit = layui.layedit;
        index = layedit.build('demo',{
            tool: ['strong' //加粗
                ,'italic' //斜体
                ,'underline' //下划线
                ,'del' //删除线
                ,'left' //左对齐
                ,'center' //居中对齐
                ,'right' //右对齐
            ]}
        ); //建立编辑器
        layedit.getContent(index)
    });
</script>
<script>
    //更新
    $("#add").click(function(){
        var id = $("#id").val();
        var title = $("#title").val();
        var content = layedit.getContent(index);
        $.ajax({
            url:"{:url('/schoolNotice/noticeUpdate')}",
            data:{id:id,title:title,content:content},
            type:"post",
            dataType:"json",
            success:function (res) {
                if(res.code){
                    layer.msg(res.msg,{icon:1,time:2000},function(){
                        $("#adminList").bootstrapTable(('refresh'));
                    });
                    return;
                }else{
                    layer.msg(res.msg,{icon:5,time:2000});
                    return;
                }
            }
        })
    })
    //返回
    $("#back").click(function () {
        window.history.go(-1)
    })
</script>